#include<iostream>
#include<cmath>
using namespace std;

void fillArray(int** arr, int rows, int cols) {
    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            arr[i][j] = rand() % 10 + 1;
        }
    }
}

void printArray(int** arr, int rows, int cols) {
    for (int i = 0; i < rows; ++i) {
        for (int j = 0; j < cols; ++j) {
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
}


int main()
{
    srand((unsigned) time(0));
    
    int rows=5,cols=5;
    
    int **arr =new int *[rows];
    for(int i=0;i<rows;i++){
        arr[i]=new int [cols];
    }

    fillArray(arr,rows,cols);
    printArray(arr,rows,cols);

    // 销毁动态空间
    for (int i = 0; i < rows; ++i) {
        delete[] arr[i];
    }
    delete[] arr;
    return 0;
}